Handling Globalization Aspects in Web Application Development |
|
In a global scenario, application users across various countries speak different languages and are accustomed to local conventions for formatting and display of information. To be able to serve users better, you may need to globalize your applications for various countries.
Globalization includes the internationalization and translation of an application.
Process Platform has the infrastructure necessary to support internationalization. You can also internationalize the Process Platform infrastructure, including the Explorer and the Wizards. It is possible to translate the Explorer, its web components, and the web pages generated using the Web Generator to different languages such as Chinese and Hebrew.
Process Platform is UTF8 enabled, that is it supports Multi-byte characters. The web pages generated by the Web Generator are also UTF8 enabled. Apart from this, Process Platform provides the Web Components - translator and globalization, which help in internationalization.
The translator component enables the translation of Process Platform web pages to other languages. It also enables the translation of the menu tree in the explorer to other languages. This component also enables localization of styles to suit requirements.
The globalization component enables the conversion of different units of measurement to the required format. Using this component, units such as date and time can be localized for internationalization. Globalization is also available as a Java class for enabling this conversion for back end applications.
It is also possible to have the LDAP entries and Metadata Explorer entries in Chinese and Hebrew.
- Translate the explorer menu as follows.
- Create a dictionary file for the translation and store it under /cordys/wcp/admin/explorer.translation. This dictionary would contain all possible terms that can be translated and their equivalents in other languages (such as Chinese and Hebrew). By default, Process Platform provides a dummy file in this location. This dummy file has to be updated with the required content. As an example, see Demo code for Translator library, to see the usage of the dictionary by the translator component.
- In the explorer.htm page, the translation file is already attached to the translator component. Once the dictionary is updated with XML content, the page is refreshed with the change in language (similar to the regional settings of the Control Panel). The explorer gets translated according to the translation text specified in the dictionary.
- To provide a custom dictionary for the daemon page, or to provide translation for the new tree items added to the explorer tree, the following line of code has to be written in the application page being opened.
here "Menu" is the id of the application var menuApplication= system.windows["Menu"]; menuApplication may not be running always, therefore ensure you get the proper application before attaching the dictionary. if (menuApplication) { menuApplication.translator.appendDictionary(sURL); }
where,sURLdenotes the URL of the translator document.
Note: The Unified Feedback Objects (UFO) framework does not support translation.
- Translate the Process Platform wizards. To do so, prepare a dictionary file as mentioned in the step 1. Once the dictionary is ready, the wizard content needs to be modified accordingly as follows:
- Attach the translator component to the main wizard page.
- When the translator is loaded, the "onactive" event will be fired, which calls the function handler. The wizard properties such as caption and description are made translatable by translating the text in the handler, as shown below
function translateElements() { var itemCaptions = wizard.wizardData.selectNodes(".//step/caption"); for (var caption = itemCaptions.nextNode(); caption; caption = itemCaptions.nextNode()) caption.text = translator.translate(caption.text); }
The code above will translate all the elements like caption and description of the Wizard page to the corresponding language.
- Translate Web pages. To do so, use the Web Generator to generate web pages that are automatically UTF8 enabled, that is translatable. For already generated web pages,
- Include the translator component in the HTML page:
<div cordysType = "wcp.library.util.Translator" </div>
For a translator component, an ID need not be specified. If not specified, the default identifier will be "translator". - For each of the tokens in the page that needs to be translated, include the translatable property whose value can be set to true as in the following <LABEL> tag.
<LABEL translatable="true">This is a text</LABEL>
- If the text that is to be translated is too long, it can be referenced in the dictionary file using a label ID. This is shown below for a menuitem inside the context menu.
<div menuitem translatable=true label_id="lbl1">This is a long text, which uses a label_id for translation</div>
- Include the translator component in the HTML page:
- Localize date and time. Use the globalization component to localize date and time to suit the requirement. To do so, add the following code in the HTML page:
<div "wcp.library.util.Globalization" id=globalID> </div>
where,globalID denotes the ID of the component attached to the page.
The getlocaleDate() method of the Globalization component can be used to get the local equivalent of a given UTC (Universal Time Coordinated) date. It takes the date object as an input. For details, see Globalization.
The web application is globalized.Note: In the context of Metadata Services, there is a limitation in the Chinese character support for MS-Access. Currently ODBC bridge is used to connect to MS-Access. But, that does not work for Chinese metadata. For Chinese support for MS-Access metadata, the Jet OLE DB provider needs to be used to get metadata and generate methods. The Provider name here is Microsoft.Jet.OLEDB.4.0 and the Data source is the file path (for example, d:\Northwind.mdb). Please note that the Jet OLE DB provider can only be used for populating the metadata, but cannot be used for data access.